<%@page import="notification.NotifManager"%>
<%@page import="login.UserModel"%>

<%
	UserModel user = (UserModel)session.getAttribute("userLogin");
// 	if(user == null){
// 		response.sendRedirect("/WebFinalProject/Login.do");
// 	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/FinalProjectCSS.css"/>

<script type="text/javascript">

	// slight update to account for browsers not supporting e.which
	function disableF5(e, task) { 
		if ((e.which || e.keyCode) == 116) {
			if((document.forms[0].task.value.indexOf("insert") != -1) || 
				(document.forms[0].task.value.indexOf("update") != -1) ||
				(document.forms[0].task.value.indexOf("delete") != -1))	{
				e.preventDefault(); 
				document.forms[0].task.value = task;
				document.forms[0].submit();
			}		
		}
	}
	
	function changePage(task){
		if(task == "logout"){
			window.location = "/WebFinalProject/Login.do";
		}else{
			document.forms[0].task.value = task;
			document.forms[0].submit();
		}
	}
	
</script>
</head>
<body>

<table width="100%" cellpadding="0" cellspacing="0" class="headerBox blueBackground" height="90px" style="border-bottom: 1px solid #3e3d3c;">
	<tr>
		<td align="left" style="vertical-align:middle;">
			<img src="images/logo.png" class="logoStyle"/>
		</td>
		<td align="right" style="vertical-align:bottom;">
			<table height="100%" style="border-spacing: 10px;">
				<tr>
					<td colspan="3" height="50%" align="right">
						<%java.text.DateFormat df = new java.text.SimpleDateFormat("EEEE, dd MMMM yyyy"); %>
						<%= df.format(new java.util.Date()) %>
<%-- 						<%= new java.util.Date().toGMTString() %> --%>
					</td>
				</tr>
				<tr>
					<td style="vertical-align:middle;">
					  <a href="javascript:void(0)" onclick="javascript:changePage('showNotif');">
						<input type="button" id="btnNotif" value="0" style="cursor:pointer;"/>
						</a>
					</td>
					<td style="vertical-align:middle;">
						<input type="button" class="menuBoxUserName greyBackground" value='<%= user.getUserid()%>'/>
					</td>
					<td><a href="javascript:changePage('logout');" title="logout"><img src="images/logout.png" height="40px" alt="logout" border="0"/></a></td>
				</tr>
			</table>
		</td>
	</tr>
</table>

<script type="text/javascript">
	document.getElementById("btnNotif").value = <%= new NotifManager().getNumOfNotif(user.getUserid())%> ;
	document.getElementById("btnNotif").setAttribute("title", document.getElementById("btnNotif").value);
	if(document.getElementById("btnNotif").value > 0){
		document.getElementById("btnNotif").setAttribute("class", "notifBox menuNotifButton redBackground");
	}else{
		document.getElementById("btnNotif").setAttribute("class", "menuNotifButton greyBackground");
	}
</script>

</body>
</html>